from django.conf.urls import url

from booktest import views_14路由router的使用

urlpatterns = [
    # url(r'^books/$', views.BookInfoViewSet.as_view({
    #     'get':'list',
    #     'post':'create'
    # }),name='books-list'),
    # url(r'^books/(?P<pk>\d+)/$', views.BookInfoViewSet.as_view({
    #     'get':'retrieve',
    #     'put':'update',
    #     'delete':'destroy'
    # }),name='books-detail'),
    # url(r'^books/latest/$', views.BookInfoViewSet.as_view({
    #     'get':'latest'
    # }),name='books-latest'),
    # url(r'^books/(?P<pk>\d+)/read/$', views.BookInfoViewSet.as_view({
    #     'put':'read'
    # }),name='books-read')
]
# 1.创建Router对象
from rest_framework.routers import SimpleRouter
router = SimpleRouter()

# 2.注册视图集
router.register( 'books', views_14路由router的使用.BookInfoViewSet, base_name='books')

# 3.将生成的url配置项添加到urlpatterns中
urlpatterns += router.urls
